package com.bloom;

import com.bloom.service.RedisService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.*;

@SpringBootApplication
public class Application {
    private static final String key = "bloom_test";

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);

        System.out.println("------test--start--------");
        RedisService redisService = context.getBean(RedisService.class);

        System.out.println("------add--start--------");

        Set<String> set = new HashSet<String>(1000);
        List<String> list = new ArrayList<String>(1000);
        for (int i = 0; i < 100000; i++) {
            String uuid = UUID.randomUUID().toString();
            if(i<1000){
                set.add(uuid);
                list.add(uuid);
            }
            redisService.addByBloomFilter(key, uuid);
        }

        for (int i = 0; i < 10; i++) {
            String uuid = UUID.randomUUID().toString();
            list.add(uuid);
        }

        System.out.println("------search--start--------");

        for (String k: list){
            System.out.println("-------------" + k + "--------------");
            System.out.println(redisService.includeByBloomFilter(key, k));
            System.out.println("-------------" + k + "--------------");
        }

    }

}
